<?php

/**
 * This is the model class for table "notas".
 *
 * The followings are the available columns in table 'notas':
 * @property integer $id
 * @property integer $NOT_N
 * @property integer $NOT_A
 * @property string $CARATULA
 * @property string $FECINS
 * @property string $NOT_E
 * @property string $NOT_L
 * @property string $CIRCUN
 * @property string $SECCION
 * @property integer $CHACRA
 * @property integer $QUINTA
 * @property string $FRACCION
 * @property integer $MANZ
 * @property integer $PARCELA
 * @property string $OBS_NOT
 */
class notas extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'notas';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('NOT_N, NOT_A, CARATULA', 'required'),
			array('NOT_N, NOT_A, CHACRA, QUINTA, MANZ, PARCELA', 'numerical', 'integerOnly'=>true),
			array('CARATULA', 'length', 'max'=>40),
			array('NOT_E, NOT_L', 'length', 'max'=>50),
			array('CIRCUN, SECCION, FRACCION', 'length', 'max'=>5),
			array('OBS_NOT', 'length', 'max'=>5000),
			array('FECINS', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, NOT_N, NOT_A, CARATULA, FECINS, NOT_E, NOT_L, CIRCUN, SECCION, CHACRA, QUINTA, FRACCION, MANZ, PARCELA, OBS_NOT', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'expedientes' => array(self::HAS_MANY, 'Expedientes', 'nota_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'Id',
			'NOT_N' => 'Numer',
			'NOT_A' => 'Año',
			'CARATULA' => 'Caratula',
			'FECINS' => 'Fecha ',
			'NOT_E' => 'Estado',
			'NOT_L' => 'Ubicacion',
			'CIRCUN' => 'Circun',
			'SECCION' => 'Seccion',
			'CHACRA' => 'Chacra',
			'QUINTA' => 'Quinta',
			'FRACCION' => 'Fraccion',
			'MANZ' => 'Manz',
			'PARCELA' => 'Parcela',
			'OBS_NOT' => 'Obs Not',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);

		$criteria->compare('NOT_N',$this->NOT_N);

		$criteria->compare('NOT_A',$this->NOT_A);

		$criteria->compare('CARATULA',$this->CARATULA,true);

		$criteria->compare('FECINS',$this->FECINS,true);

		$criteria->compare('NOT_E',$this->NOT_E,true);

		$criteria->compare('NOT_L',$this->NOT_L,true);

		$criteria->compare('CIRCUN',$this->CIRCUN,true);

		$criteria->compare('SECCION',$this->SECCION,true);

		$criteria->compare('CHACRA',$this->CHACRA);

		$criteria->compare('QUINTA',$this->QUINTA);

		$criteria->compare('FRACCION',$this->FRACCION,true);

		$criteria->compare('MANZ',$this->MANZ);

		$criteria->compare('PARCELA',$this->PARCELA);

		$criteria->compare('OBS_NOT',$this->OBS_NOT,true);

		return new CActiveDataProvider('notas', array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * @return notas the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}